import request from '@/utils/request'

// 供应商
export function supplier(query) {
  return request({
    url: '/erp_api/zhouyz/supplier/list',
    method: 'get',
    params: query
  })
}

// 供应商详情
export function supplierDetail(query) {
  return request({
    url: `/erp_api/zhouyz/supplier/${query.id}`,
    method: 'get'
  })
}

// 采购付款
export function purchasePayment(query) {
  return request({
    url: '/erp_api/zhouyz/payment/list',
    method: 'get',
    params: query
  })
}

// 采购单
export function purchaseOrder(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/list',
    method: 'get',
    params: query
  })
}


// 供应商全部信息
export function allSupplier(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/all-supplier',
    method: 'get',
    params: query
  })
}
// 采购单作废
export function purchaseInvalid(data) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/invalid',
    method: 'post',
    data: data
  })
}
// 采购单发起审核
export function launchExamineOrder(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/launch-examine-order',
    method: 'get',
    params: query
  })
}
// 采购单审核
export function examineOrder(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/examine-order',
    method: 'get',
    params: query
  })
}
// 采购单确认发货
export function sureSend(data) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/sure-send/update-date',
    method: 'post',
    data: data
  })
}
// 采购单确认收货
export function sureReceiving(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/sure-receiving',
    method: 'get',
    params: query
  })
}
// 采购单入库
export function sureJoinWarehouse(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/sure-join-warehouse',
    method: 'get',
    params: query
  })
}
// 采购单财务审核
export function saveFinanceAudit(data) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/save-finance-audit',
    method: 'post',
    data: data
  })
}

// 采购单删除
export function delPurchaseOrder(data) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder/remove',
    method: 'delete',
    data: data
  })
}
// 新增采购单
export function purchaseOrderAdd(data) {
  return request({
    url: '/erp_api/zhouyz/purchaseOrder',
    method: 'post',
    data: data
  })
}

// 采购单详情
export function purchaseOrderDetail(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseOrder/${query.id}`,
    method: 'get'
  })
}

// 采购单获取商品最新价格
export function purchaseOrderNewPrice(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseOrder/new-price/${query.id}`,
    method: 'get'
  })
}
// 修改采购单商品
export function purchaseOrderUpdateProducts(query, data) {
  return request({
    url: `/erp_api/zhouyz/purchaseOrder/update-products/${query.id}`,
    method: 'put',
		data: data
  })
}
// 供应商商品
export function supplierProduct(query) {
  return request({
    url: '/erp_api/zhouyz/supplierProduct/list',
    method: 'get',
    params: query
  })
}


// 一个供应商所有商品
export function supplierProductById(query) {
  return request({
    url: '/erp_api/zhouyz/supplierProduct/product-list-by-id',
    method: 'get',
    params: query
  })
}

// 供应商商品详情
export function supplierProductDetail(query) {
  return request({
    url: `/erp_api/zhouyz/supplierProduct/${query.id}`,
    method: 'get'
  })
}
// 供应商商品编辑
export function editSupplierProduct(data) {
  return request({
    url: data.id?`/erp_api/zhouyz/supplierProduct`:`/erp_api/zhouyz/supplierProduct/add-product`,
    method: data.id?'put':'post',
		data: data
  })
}
// 供应商商品删除
export function delSupplierProduct(data) {
  return request({
    url: `/erp_api/zhouyz/supplierProduct/${data.id}`,
    method: 'delete'
  })
}
// 采购需求
export function purchaseDemand(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseDemand/list',
    method: 'get',
    params: query
  })
}

// 采购需求详情
export function purchaseDemandDetail(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseDemand/${query.id}`,
    method: 'get'
  })
}

// 采购需求商品
export function purchaseDemandProduct(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseDemandProduct/list',
    method: 'get',
    params: query
  })
}

// 采购需求仓库
export function purchaseDemandWarehouse(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseDemand/warehouse-list-by-demandId/${query.id}`,
    method: 'get'
  })
}

// 销售需求汇总
export function salesmanDemandProductSummary(query) {
  return request({
    url: '/erp_api/zhouyz/salesmanDemand/product/summary',
    method: 'get',
    params: query
  })
}

// 销售需求汇总详情
export function salesmanDemandProductSummaryDetail(query) {
  return request({
    url: `/erp_api/zhouyz/salesmanDemand/product/summary-detail`,
    method: 'get',
    params: query
  })
}

// 采购退货
export function purchaseReturn(query) {
  return request({
    url: '/erp_api/zhouyz/purchaseReturn/list',
    method: 'get',
    params: query
  })
}

// 采购退货详情
export function purchaseReturnDetail(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseReturn/${query.id}`,
    method: 'get'
  })
}

// 采购退货商品
export function purchaseReturnProduct(query) {
  return request({
    url: `/erp_api/zhouyz/purchaseReturnProduct/list-return-id/${query.id}`,
    method: 'get'
  })
}
